package org.ns.example;

import org.ns.entity.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserService {
    @Autowired
    Environment env;
    // 获取用户的昵称
    public String getNickName(long userId) {
        return "nick-" + userId + ":server:" + env.getProperty("rpc.server.register.port", "NONE");
    }

    // 登录一下 username = admin, password = 123456
    public String login(String username, String password) {
        if ("admin".equals(username) && "123456".equals(password)) {
            return "登录成功";
        } else {
            return "登录失败";
        }
    }

    // 获得用户信息
    public UserInfo getUserInfo(long userId) {
        UserInfo userInfo = new UserInfo();
        userInfo.setUserId(userId);
        userInfo.setHeadPic(userId + "的头像");
        userInfo.setNickname("nick-" + userId);
        return userInfo;
    }


//    public boolean
}
